/*package com.fruit.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

import org.joda.time.DateTime;


public class OSSUtils {
	
	private final static String endpoint="oss-cn-beijing.aliyuncs.com";        
	private final static String accessKeyId="LTAI8TMIkxf13y1L";       
	private final static String accessKeySecret="ksHctFeFg47zzBUEQ2SoslfIfjbOpl";     
	private final static String bucketName="fruit-picture-private";      
	private final static String picLocation="fruit/goods/"; 
	 
    
    *//** 
     *  
     * @MethodName: pictureUpload 
     * @Description: 文件上传
     * @param MultipartFile  上传文件
     * @return url
     *//*  
    public static Map<String, Object> pictureUpload(MultipartFile uploadFile){  
    	Map<String, Object> resultMap = new HashMap<String, Object>();
    	String url=null;
		OSSClient ossClient=null;
		String resultStr = null;
		try {
			ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
	        CommonsMultipartFile cf= (CommonsMultipartFile)uploadFile; 
	        DiskFileItem fi = (DiskFileItem)cf.getFileItem(); 
	        File f = fi.getStoreLocation();
	        String imagePath = new DateTime().toString("yyyy-MM-dd");
	        String newName = IDUtils.genImageName();
	        String fileName=picLocation+imagePath+"/"+newName+".png";
            InputStream input = new FileInputStream(f);    
            ObjectMetadata meta = new ObjectMetadata(); 
            meta.setContentLength(f.length()); 
            meta.setContentType("image/jpeg");
            meta.setCacheControl("no-cache");
            meta.setContentEncoding("utf-8"); 
            PutObjectResult putResult = ossClient.putObject(bucketName, fileName,input,meta); 
            resultStr=putResult.getETag();
            url = "http://"+bucketName+"."+endpoint+"/"+fileName;
            resultMap.put("error", 0);
			resultMap.put("url", url);
		} catch (Exception e) {
			e.printStackTrace();
			resultMap.put("error", 1);
			resultMap.put("message", "文件上传发生异常");
		} finally {  
            ossClient.shutdown();  
        } 
        return resultMap;  
    } 
    
    *//** 
     *  
     * @MethodName: deleteFile 
     * @Description: 单文件删除 
     * @param fileUrl 需要删除的文件url 
     * @return boolean 是否删除成功 
     *//*  
    public static boolean deleteFile(String fileUrl){  
        String bucketName = OSSUtils.getBucketName(fileUrl);       
        String fileName = OSSUtils.getFileName(fileUrl);           
        if(bucketName==null||fileName==null) return false;  
        OSSClient ossClient = null;   
        try {  
        	ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);   
            GenericRequest request = new DeleteObjectsRequest(bucketName).withKey(fileName);  
            ossClient.deleteObject(request);  
        } catch (Exception oe) {  
            oe.printStackTrace();  
            return false;  
        } finally {  
            ossClient.shutdown();  
        }  
        return true;  
    }  

    *//** 
     *  
     * @MethodName: getBucketName 
     * @Description: 根据url获取bucketName 
     * @param fileUrl 文件url 
     * @return String bucketName 
     *//*  
    private static String getBucketName(String fileUrl){  
        String http = "http://";  
        String https = "https://";  
        int httpIndex = fileUrl.indexOf(http);  
        int httpsIndex = fileUrl.indexOf(https);  
        int startIndex  = 0;  
        if(httpIndex==-1){  
            if(httpsIndex==-1){  
                return null;  
            }else{  
                startIndex = httpsIndex+https.length();  
            }  
        }else{  
            startIndex = httpIndex+http.length();  
        }  
        int endIndex = fileUrl.indexOf(".oss-");   
        return fileUrl.substring(startIndex, endIndex);  
    }  
      
    *//** 
     *  
     * @MethodName: getFileName 
     * @Description: 根据url获取fileName 
     * @param fileUrl 文件url 
     * @return String fileName 
     *//*  
    private static String getFileName(String fileUrl){  
        String str = "aliyuncs.com/";  
        int beginIndex = fileUrl.indexOf(str);  
        if(beginIndex==-1) return null;  
        return fileUrl.substring(beginIndex+str.length());  
    } 
}
*/